<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="co.kr.teamcloud.group.service.*" %>
<%@ page import="com.google.appengine.api.users.*" %>
<%@ page import="com.google.appengine.api.datastore.*" %>       
<%
	String groupNm = request.getParameter("groupNm");		//그룹 명
	String groupDc = request.getParameter("groupDc");		//그룹 설명
	String othbcAt = request.getParameter("othbcAt");		//공개 여부
    		
	UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    
    //로그인 사용자만 접근
    if( user != null ) {
	    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
	    
	    Date today = new Date();
	    
	    //저장할 데이터
	    Key groupKey = KeyFactory.createKey("teamcloud", "group");
	    Entity group = new Entity("group", groupKey);
	    group.setProperty("groupNm", groupNm);
	    group.setProperty("groupCn", groupDc);
	    group.setProperty("othbcAt", othbcAt);
	    group.setProperty("frstRegisterId", user.getUserId());
	    group.setProperty("frstRegistPnttm", today);
	    group.setProperty("lastUpdusrId", user.getUserId());
	    group.setProperty("lastUpdtPnttm", today);
	    group.setProperty("googleUser", user);
	    
	    //데이터 저장
	    datastore.put(group);
    }
    
  //  response.sendRedirect("/group/groupList.jsp");
%>
<script>
	alert('등록되었습니다.');
	location.href='groupList.jsp';
</script>
